package TUILag;
/**
 * Handles the main menu of the system
 * 
 * @author (Lackshan, Mikkel, Nick, Patrick, Simon, Yousef) 
 * @project (Tema design)
 * @version (2014.11.04)
 */
public class MainMenuTUI
{
    private InputReader reader = InputReader.getInstance();

    /**
     * Constructor for objects of class MainMenuUI
     */
    public MainMenuTUI(){
    }
    
    /**
     * Runs the main menu loop
     */
    public void run(){
        boolean finished = false;
        printMainMenu();
        
        while(!finished) {
            // get the user inpit from the reader
            String choise = reader.getInput();

            switch(choise){
                case "1": 
                    PersonTUI personTUI = new PersonTUI();
                    personTUI.run();
                    printMainMenu();
                    break;
                case "2": 
                    DVDTUI dvdTUI = new DVDTUI();
                    dvdTUI.run();
                    printMainMenu();
                    break;
                case "3":
                    finished=true;
                    LoanTUI loanTUI = new LoanTUI();
                    loanTUI.run();
                    printMainMenu();
                    break;
                case "4":
                    finished=true;
                    System.out.println("Bye!");
                    break;
                default:
                    System.out.println("Not a command");
                
            }

        }
    }
    
    /**
     * Prints the main menu to the terminal
     */
    private void printMainMenu(){
        System.out.println("*****************\n ** Main Menu **\n*****************");
        System.out.println(" 1. Friends");
        System.out.println(" 2. DVDs");     
        System.out.println(" 3. Loan");
        System.out.println(" 4. Close");
    }
}
